	<?php include PATH_TPL."/admin/tpl.header.phtml"?>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>新增配餐
                        </li>
                    </ol>
                </div>
            </div>
            <div id="page-wrapper">
                <div class="container-fluid col-md-7 col-sx-12">
                    <form method="post" enctype="multipart/form-data" name="cater">
                        <div class="form-group"style="margin-left:px">
                           <!--<label for="department"><strong>所在部门：</strong></label>                           
                            <select name="department" t>
                                <option value="0">请选择</option>
                                <?foreach($tDIDatas as $tDRow){?>
                                <option value="<?=$tDRow['num']?>"><?=$tDRow['introduce']?></option>
                                <?}?>
                            </select><--></-->

			
                        <div class="form-group">
                            <span>配餐时间：</span>
			    <input type="text" style="" name="startcreated" id="startdatetime" placeholder="开始时间" value="<?=$tDates['0']?>" onclick="WdatePicker();"/>—————<input type="text" name="endcreated" id="enddatetime" placeholder="结束时间" value="" disabled="true"/><button type="button" id="dattime" class="btn btn-blue" style="height:30px;border-radius:10%;margin-left:20px;">
			    <span style="position:relative;bottom:9px;" class="text">确定</span> </button><button type="button" id="save" class="btn btn-blue" style="height:30px;text-align:top;border-radius:10%;margin-left:536px;"><span style="position:relative;bottom:9px;" class="text">保存</span></button>           
			    <input type="text"  name="tian" id="tian" value="7" style="display:none">   
                <div class="form-group"><input type="text" value="<?=$tDates['0']?>" style="display:none" name="datetime0" id="datetime0"/><label for="name"><strong>周一</strong></label><br><span style="margin-left:20px;">早上配餐</span><input type="text" name="breakfast0" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input type="text" name="lunch0" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input type="text" name="dinner0" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input type="text" name="other0" style="margin-left:45px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></div> 

                <div class="form-group"><input type="text" value="<?=$tDates['1']?>" style="display:none" name="datetime1" id="datetime1"/><label for="name"><strong>周二</strong></label><br><span style="margin-left:20px;">早上配餐</span><input type="text" name="breakfast1" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input type="text" name="lunch1" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input type="text" name="dinner1" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input type="text" name="other1" style="margin-left:45px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></div>

                <div class="form-group"><input type="text" value="<?=$tDates['2']?>" style="display:none" name="datetime2" id="datetime2" /><label for="name"><strong>周三</strong></label><br><span style="margin-left:20px;">早上配餐</span><input type="text" name="breakfast2" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input type="text" name="lunch2" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input type="text" name="dinner2" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input type="text" name="other2" style="margin-left:45px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></div>

                <div class="form-group"><input type="text" value="<?=$tDates['3']?>" style="display:none" name="datetime3" id="datetime3" /><label for="name"><strong>周四</strong></label><br><span style="margin-left:20px;">早上配餐</span><input type="text" name="breakfast3" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input type="text" name="lunch3" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input type="text" name="dinner3" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input type="text" name="other3" style="margin-left:45px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></div>

                <div class="form-group"><input type="text" value="<?=$tDates['4']?>" style="display:none" name="datetime4" id="datetime4" /><label for="name"><strong>周五</strong></label><br><span style="margin-left:20px;">早上配餐</span><input type="text" name="breakfast4" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input type="text" name="lunch4" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input type="text" name="dinner4" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input type="text" name="other4" style="margin-left:45px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></div>

                <div class="form-group"><input type="text" value="<?=$tDates['5']?>" style="display:none" name="datetime5" id="datetime5" /><label for="name"><strong>周六</strong></label><br><span style="margin-left:20px;">早上配餐</span><input type="text" name="breakfast5" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input type="text" name="lunch5" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input type="text" name="dinner5" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input type="text" name="other5" style="margin-left:45px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></div>  

                <div class="form-group"><input type="text" value="<?=$tDates['6']?>" style="display:none" name="datetime6" id="datetime6" /><label for="name"><strong>周日</strong></label><br><span style="margin-left:20px;">早上配餐</span><input type="text" name="breakfast6" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">中午配餐</span><input type="text" name="lunch6" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;align:center"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">晚上配餐</span><input type="text" name="dinner6" style="margin-left:20px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></br><span style="margin-left:20px;">其他</span><input type="text" name="other6" style="margin-left:45px;margin-top:20px;" value=""></br><div style="margin-left:71px;margin-top:20px;"><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/><img src=""  alt="" height="100px" weight="100px"style="margin-top:20px;"/></div></div>        
                        </div>
                        <div id="cater">
						</div>
                       <!--  <button class="btn btn-primary demo_2" type="button" id="submit">添加</button> -->
                    </form>   
                </div>
                </div>
                <div class="subviews">
                    <div class="subviews-container"></div>
                </div>
            </div>
            <!-- end: PAGE -->
        </div>
    </div>
</div>
<!-- end: MAIN CONTAINER -->
<script type="text/javascript" src="/plugins/jquery-ui-1.11.4/jquery-ui.min.js"></script>
 <script type="text/javascript" src="/plugins/medialog/mdialog.js"></script><!--medialog -->
 <script type="text/javascript" src="/plugins/medialog/zepto.min.js"></script><!--zepto -->
 <script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
<script>
var w_id = '';
    //所在部门与姓名绑定显示
    $('select[name="department"]').on('change',function(){
        var department_id = $(this).val();
        // alert(0);
        $.get('/admin_cater/add',{department_id:department_id},function(obj){
            $
            if (obj.status==1) {
                $('#startdatetime').val(obj.data['0']);
                $('#startdatetime').removeAttr('disabled');
                $('#enddatetime').val(obj.data['6']);
            }else{
                $('#startdatetime').val(obj.data['0']);
                $('#startdatetime').attr('disabled',true);
                $('#enddatetime').val(obj.data['6']);
            }
            for ( i = 0; i < 7; i++) {
                $('#datetime'+i).val(obj.data[i])
            }
        });
    });
    $('select[name="role"]').on('change',function(){
        var role = $(this).val();
        w_id = $('select[name="w_id"]').val();
        $.get('/admin_cater/add',{role:role,w_id:w_id},function(obj){
            if(obj.status ==  1){
                var data = obj.data;
                $('input[name="department[]"]').remove();
                $('.introduce').remove();
                for(i in data){
                    $('.department').after('<input type="checkbox" name="department[]" value="'+data[i].num+'" style="margin-left:20px;"/><span class="introduce">'+data[i].introduce+'</span>');
                }
            }
        });
    });
    $('#save').click(function(){
        $('#enddatetime').removeAttr('disabled');
        var data = $('form[name="cater"]').serialize();
        $.post('/admin_cater/add',data,function(obj){
            cg_alert_add(obj,'/admin_cater/','/admin_cater/add');
            $('#enddatetime').attr('disabled',true);
        });
    });
    $('#dattime').on("click",function() { 
    	$('#cater').empty('.form-group');
    	var startdatetime = $('#startdatetime').val();
 		var startDatetime = new Date(Date.parse(startdatetime));
 		var today = new Array('周日','周一','周二','周三','周四','周五','周六'); 
 		var Monthes = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
 		var Day = new Array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
 		var Month_Days = new Array('01','03','05','07','08','10','12'); 
 		var Year = startDatetime.getFullYear();	//获取餐配开始时间的年份
 		var Month = startDatetime.getMonth();	//获取餐配开始时间的月份
 		var Days = startDatetime.getDate();		//获取餐配开始时间的日期
 		var Week = startDatetime.getDay()==0?7:startDatetime.getDay();		//获取餐配开始时间的星期
 		//alert(Week)
 		var Ndays = 7-Week;
 		//alert(Ndays);
 		var agin = 1;
 		var str = "";
 		if (Week!=0) {
 			if (Week!=1) {
 				swal("请选择本周周一");
 			}
 			for (var i = 0; i <= Ndays; i++) {
 		 		var d = Days+i;
 		 		var w = Week+i;
 		 		//alert(w);
 		 		if (w==7) {
 		 			var Weeks = "周日";
 		 		}else{
 		 			var Weeks = today[w];
 		 		}
 		 		//alert(Weeks);
 		 		if ($.inArray(Monthes[Month],Month_Days)>=0) {
 		 			//alert(1)
 		 			if(Month==11){
	 		 			if (d>31) {
		 		 			var day = Day[agin++];
		 		 			var endmonth = Monthes[0];
		 		 			var endYear = Year+1;
		 		 			var datetime = endYear+"-"+endmonth+"-"+day;
		 		 		}else{
		 		 			var day = Day[d];
		 		 			var endmonth = Monthes[Month];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		}

	 		 		}else{
	 		 			if (d>31) {
		 		 			var day = Day[agin++];
		 		 			var endmonth = Monthes[Month+1];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		}else{
		 		 			var day = Day[d];
		 		 			var endmonth = Monthes[Month];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		}
	 		 		}
 		 		}else if (Month==1) {
 		 			if (Year%4==0) {
 		 				if (d>29) {
		 		 			var day = Day[agin++];
		 		 			var endmonth = Monthes[Month+1];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		} else{
		 		 			var day = Day[d];
		 		 			var endmonth = Monthes[Month];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		}
 		 			}else{
 		 				if (d>28) {
		 		 			var day = Day[agin++];
		 		 			var endmonth = Monthes[Month+1];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		} else{
		 		 			var day = Day[d];
		 		 			var endmonth = Monthes[Month];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		}
 		 			}
 		 		}else{
 		 				if (d>30) {
		 		 			var day = Day[agin++];
		 		 			var endmonth = Monthes[Month+1];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		}else{
		 		 			var day = Day[d];
		 		 			var endmonth = Monthes[Month];
		 		 			var datetime = Year+"-"+endmonth+"-"+day;
		 		 		}
 		 		}
 		 		if (i==Ndays) {
 		 			$('#enddatetime').val(datetime);
 		 			//alert(datetime);
 		 			    $.get('/admin_cater/add',{enddatetime:datetime},function(obj){
 		 			    	swal(obj.msg);  
 		 			    	//alert(obj)
			            if(obj.status ==  1){
			                var data = obj.data;
			                $('input[name="department[]"]').remove();
			                $('.introduce').remove();
			                for(i in data){
			                    $('.department').after('<input type="checkbox" name="department[]" value="'+data[i].num+'" style="margin-left:20px;"/><span class="introduce">'+data[i].introduce+'</span>');
			                }
			            }
			        });
 		 		}
 		 	} 
 		}
 		$('#cater').append(str);
 		//alert(str)
	});
</script>
<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
